package com.keyancompany.zhongbaopingtai.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.keyancompany.zhongbaopingtai.R;
import com.nostra13.universalimageloader.core.ImageLoader;

/**
 * Created by firefox on 2016/6/5.
 */
public class MineMenuAdapter extends ListAdapter<String> {
    String[] names;
    int[] icons = {R.mipmap.icon_project,R.mipmap.icon_collection,R.mipmap.icon_complaint,
            R.mipmap.icon_team,R.mipmap.icon_cricle,R.mipmap.icon_friend};

    public MineMenuAdapter(Context ctx) {
        super(ctx);
        names = ctx.getResources().getStringArray(R.array.index_menu);
    }

    @Override
    public int getCount() {
        return names.length;
    }

    @Override
    public int getContentViewId() {
        return R.layout.item_mine_grid;
    }

    @Override
    public HolderView getHoldView(int position, View contentView, ViewGroup parent) {
        MineHolder hold = new MineHolder();
        hold.name = (TextView) contentView.findViewById(R.id.name);
        hold.icon = (ImageView) contentView.findViewById(R.id.icon);
        return hold;
    }

    @Override
    public void setItemView(int position, HolderView contentView, String item) {
        MineHolder hold = (MineHolder) contentView;
        hold.name.setText(names[position]);
        hold.icon.setImageResource(icons[position]);
//        ImageLoader.getInstance().displayImage(Uri.p,hold.icon);
    }

    class MineHolder extends HolderView {
        TextView name;
        ImageView icon;

    }
}
